/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import DAO.Iter.HocKyDAO;
import TableModel.Hocky;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;


/**
 *
 * @author vt
 */
public class HocKyDAOImpl extends HibernateDaoSupport implements HocKyDAO {

    @Override
    public List<Hocky> findAllHocKy() {
        return getHibernateTemplate().find("from Hocky");
    }

    @Override
    public void update(Hocky id) {      
       id.toString();
        getHibernateTemplate().saveOrUpdate(id);
    }

    @Override
    public void add(Hocky id) {
        getHibernateTemplate().save(id);
    }

    @Override
    public void delete(Hocky id) {
       getHibernateTemplate().delete(id);
    }

    @Override
    public Hocky findHocKyById(String idhocky) {
         List list = this.getHibernateTemplate().find("from Hocky hocky where hocky.mahk = ? ", idhocky);
		if(list.isEmpty()){
			return null;
		}
		return (Hocky) list.get(0);
    }
    
}
